<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import = "java.sql.Connection" %>
<%@page import = "com.sxt.bbs.db.DB" %>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Statement" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Reply Detail</title>

<script language="JavaScript1.2" type="text/javascript">

function delayURL(url) {
	var delay = document.getElementById("time").innerHTML;
	if(delay > 0) {
		delay--;
		document.getElementById("time").innerHTML = delay;
	} else {

		window.top.location.href = url;
	}
    setTimeout("delayURL('" + url + "')", 1000);
}

</script>
</head>
<body>

<%
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
int pid = Integer.parseInt(request.getParameter("pid"));
int rootId = Integer.parseInt(request.getParameter("rootId"));
String title = request.getParameter("title");
String cont = request.getParameter("cont");

Connection conn = DB.getConn();
String sql = "insert into article values (null, ?, ?, ?, ?, now(), ?)";

boolean autoCommit = conn.getAutoCommit();
conn.setAutoCommit(false);

PreparedStatement pStat = DB.createPStat(conn, sql);
pStat.setInt(1, pid);
pStat.setInt(2, rootId);
pStat.setString(3, title);
pStat.setString(4, cont);
pStat.setInt(5, 0);
pStat.executeUpdate();

Statement stat = DB.createStat(conn);
stat.executeUpdate("update article set isleaf = 1 where id = " + pid );

conn.commit();
conn.setAutoCommit(autoCommit);

DB.close(stat);
DB.close(pStat);
DB.close(conn);

%>

<span id = "time">5</span>秒后自动跳转，如果没有跳转，请点击下面链接
<a href="article.jsp">主题列表</a>
<script type="text/javascript">
	delayURL("article.jsp");
</script>


</body>
</html>
